package note;
//Description:方法重载
import java.util.Random;
import java.util.Scanner;

public class Note4_1 {
    public static void main(String[] args) {
        System.out.println("输出换行");
        System.out.println("输出不换行");
        System.out.printf("%d\n",10);
        Scanner input = new Scanner(System.in);
        while(input.hasNextInt()){
            int n = input.nextInt();
            System.out.println(n);//Ctrl+D结束
        }
        Random random = new Random();//括号内加数字会生成伪随机数
        int s = random.nextInt(100);//[0~100)括号内为最大范围且不包括   后＋数字为初始值
        int c = sumAdd(10);
        System.out.println(c);//可以直接输出 但一定要有返回值
        int a1 = 10;
        int b1 = 20;
        int c1 = 30;
        double a2 = 10.2;
        double b2 = 4.5;
        System.out.println(add(a1,b1));
        System.out.println(add(a2,b2));
        System.out.println(add(a1,b1,c1));
        //比较字符串用equals作比较if(password(" ?"))



    }
    //方法重载（Overload）：方法名相同  add  参数列表不同(int a,int b)  返回值不作要求(可以不是同一个类  继承关系上也可以)
    public static int add(int a,int b){
        return a + b;
    }
    public static int add(int a,int b,int c){
        return a + b + c;
    }
    public static double add(double a,double b){
        return a + b;
    }
    public static int sumAdd(int n){
        int sum = 0;
        for (int i = 0; i <= n; i++) {
            sum += i;

        }
        return sum;
    }
}
